<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:Sakura.Silverlight.Extensions">

	<Style TargetType="local:EditableComboBox">
		<Setter Property="Padding" Value="6,2,25,2" />
		<Setter Property="Background" Value="#FF1F3B53"/>
		<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
		<Setter Property="VerticalContentAlignment" Value="Stretch" />
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="TabNavigation" Value="Once" />
		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
		<Setter Property="BorderBrush">
			<Setter.Value>
				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
					<GradientStop Color="#FFA3AEB9" Offset="0"/>
					<GradientStop Color="#FF8399A9" Offset="0.375"/>
					<GradientStop Color="#FF718597" Offset="0.375"/>
					<GradientStop Color="#FF617584" Offset="1"/>
				</LinearGradientBrush>
			</Setter.Value>
		</Setter>
		<Setter Property="EditTextBoxStyle">
			<Setter.Value>
				<Style TargetType="TextBox">
					<Setter Property="VerticalAlignment" Value="Stretch" />
					<Setter Property="HorizontalAlignment" Value="Stretch" />
				</Style>
			</Setter.Value>
		</Setter>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="local:EditableComboBox">
					<Grid>
						<Grid.Resources>
							<Style x:Name="comboToggleStyle" TargetType="ToggleButton">
								<Setter Property="Foreground" Value="#FF333333"/>
								<Setter Property="Background" Value="#FF1F3B53"/>
								<Setter Property="BorderBrush">
									<Setter.Value>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFA3AEB9" Offset="0"/>
											<GradientStop Color="#FF8399A9" Offset="0.375"/>
											<GradientStop Color="#FF718597" Offset="0.375"/>
											<GradientStop Color="#FF617584" Offset="1"/>
										</LinearGradientBrush>
									</Setter.Value>
								</Setter>
								<Setter Property="BorderThickness" Value="1"/>
								<Setter Property="Padding" Value="3"/>
								<Setter Property="VerticalContentAlignment" Value="Stretch" />
								<Setter Property="HorizontalContentAlignment" Value="Stretch" />
								<Setter Property="Template">
									<Setter.Value>
										<ControlTemplate TargetType="ToggleButton">
											<Grid>
												<VisualStateManager.VisualStateGroups>
													<VisualStateGroup x:Name="CommonStates">
														<VisualState x:Name="Normal"/>
														<VisualState x:Name="MouseOver">
															<Storyboard>
																<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay" Storyboard.TargetProperty="Opacity" To="1"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#7FFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#CCFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#F2FFFFFF"/>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Pressed">
															<Storyboard>
																<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay2" Storyboard.TargetProperty="Opacity" To="1"/>
																<DoubleAnimation Duration="0" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#E5FFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#BCFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#6BFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#F2FFFFFF"/>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Disabled" />
													</VisualStateGroup>
													<VisualStateGroup x:Name="CheckStates">
														<VisualState x:Name="Checked">
															<Storyboard>
																<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay3" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
																<DoubleAnimation Duration="0" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
																<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#E5FFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#BCFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#6BFFFFFF"/>
																<ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#F2FFFFFF"/>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Unchecked"/>
													</VisualStateGroup>
													<VisualStateGroup x:Name="FocusStates">
														<VisualState x:Name="Focused">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">
																	<DiscreteObjectKeyFrame KeyTime="0">
																		<DiscreteObjectKeyFrame.Value>
																			<Visibility>Visible</Visibility>
																		</DiscreteObjectKeyFrame.Value>
																	</DiscreteObjectKeyFrame>
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Unfocused" />
													</VisualStateGroup>
												</VisualStateManager.VisualStateGroups>
												<Rectangle x:Name="Background" RadiusX="3" RadiusY="3" Fill="{TemplateBinding Background}" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}"/>
												<Rectangle x:Name="BackgroundOverlay" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
												<Rectangle x:Name="BackgroundOverlay2" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
												<Rectangle x:Name="BackgroundGradient" RadiusX="2" RadiusY="2" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" Stroke="#FFFFFFFF">
													<Rectangle.Fill>
														<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
															<GradientStop Color="#FFFFFFFF" Offset="0" />
															<GradientStop Color="#F9FFFFFF" Offset="0.375" />
															<GradientStop Color="#E5FFFFFF" Offset="0.625" />
															<GradientStop Color="#C6FFFFFF" Offset="1" />
														</LinearGradientBrush>
													</Rectangle.Fill>
												</Rectangle>
												<Rectangle Opacity="0" x:Name="BackgroundOverlay3" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
												<Rectangle Opacity="0" x:Name="BackgroundGradient2" RadiusX="2" RadiusY="2" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" Stroke="#FFFFFFFF">
													<Rectangle.Fill>
														<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
															<GradientStop Color="#FFFFFFFF" Offset="0" />
															<GradientStop Color="#F9FFFFFF" Offset="0.375" />
															<GradientStop Color="#E5FFFFFF" Offset="0.625" />
															<GradientStop Color="#C6FFFFFF" Offset="1" />
														</LinearGradientBrush>
													</Rectangle.Fill>
												</Rectangle>
												<Rectangle x:Name="Highlight" RadiusX="2" RadiusY="2" Opacity="0" IsHitTestVisible="false" Stroke="#FF6DBDD1" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" />
												<ContentPresenter
                                                      x:Name="contentPresenter"
                                                      Content="{TemplateBinding Content}"
                                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                      Margin="{TemplateBinding Padding}"/>
												<Rectangle x:Name="FocusVisualElement" RadiusX="3.5" Margin="1"  RadiusY="3.5" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed" IsHitTestVisible="false" />
											</Grid>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
						</Grid.Resources>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal" />
								<VisualState x:Name="MouseOver" />
								<VisualState x:Name="Disabled">
									<Storyboard>
										<DoubleAnimation Duration="00:00:00" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To=".55"/>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="FocusStates">
								<VisualState x:Name="Focused">
									<Storyboard>
										<DoubleAnimation Duration="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Unfocused"/>
								<VisualState x:Name="FocusedDropDown">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
											<DiscreteObjectKeyFrame KeyTime="00:00:00">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="ValidationStates">
								<VisualState x:Name="Valid"/>
								<VisualState x:Name="InvalidUnfocused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
											<DiscreteObjectKeyFrame KeyTime="0" >
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="InvalidFocused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
											<DiscreteObjectKeyFrame KeyTime="0" >
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
											<DiscreteObjectKeyFrame KeyTime="0" >
												<DiscreteObjectKeyFrame.Value>
													<sys:Boolean>True</sys:Boolean>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<Border x:Name="ContentPresenterBorder">
							<Grid>
								<ToggleButton x:Name="DropDownToggle" Style="{StaticResource comboToggleStyle}"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Margin="0" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition />
											<ColumnDefinition Width="auto" />
										</Grid.ColumnDefinitions>

										<Path Grid.Column="1" x:Name="BtnArrow" Height="4" Width="8" Stretch="Uniform" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " Margin="0,0,6,0" HorizontalAlignment="Right">
											<Path.Fill>
												<SolidColorBrush x:Name="BtnArrowColor" Color="#FF333333"/>
											</Path.Fill>
										</Path>

										<ContentPresenter Grid.Column="0" x:Name="ContentPresenter" 
                                                Margin="{TemplateBinding Padding}"  
                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
											<TextBlock Text=" " />
										</ContentPresenter>
										<TextBox Grid.Column="0" x:Name="EditTextBox" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" />

									</Grid>

								</ToggleButton>

							</Grid>
						</Border>
						<Rectangle x:Name="DisabledVisualElement" RadiusX="3" RadiusY="3" Fill="White" Opacity="0" IsHitTestVisible="false" />
						<Rectangle x:Name="FocusVisualElement" RadiusX="2" RadiusY="2" Margin="1"  Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
						<Border x:Name="ValidationErrorElement" BorderThickness="1" CornerRadius="1" BorderBrush="#FFDB000C" Visibility="Collapsed">
							<ToolTipService.ToolTip>
								<ToolTip x:Name="validationTooltip" Template="{StaticResource ValidationToolTipTemplate}" Placement="Right" 
                                           PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" 
                                           DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
									<ToolTip.Triggers>
										<EventTrigger RoutedEvent="Canvas.Loaded">
											<EventTrigger.Actions>
												<BeginStoryboard>
													<Storyboard>
														<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsHitTestVisible">
															<DiscreteObjectKeyFrame KeyTime="0" >
																<DiscreteObjectKeyFrame.Value>
																	<sys:Boolean>true</sys:Boolean>
																</DiscreteObjectKeyFrame.Value>
															</DiscreteObjectKeyFrame>
														</ObjectAnimationUsingKeyFrames>
													</Storyboard>
												</BeginStoryboard>
											</EventTrigger.Actions>
										</EventTrigger>
									</ToolTip.Triggers>
								</ToolTip>
							</ToolTipService.ToolTip>
							<Grid Width="12" Height="12" HorizontalAlignment="Right" Margin="1,-4,-4,0" VerticalAlignment="Top" Background="Transparent">
								<Path Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C"/>
								<Path Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" Fill="#ffffff"/>
							</Grid>
						</Border>
						<Popup x:Name="Popup">
							<Border x:Name="PopupBorder" HorizontalAlignment="Stretch" Height="Auto" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3">
								<Border.Background>
									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
										<GradientStop Color="#FFFFFFFF" Offset="0"/>
										<GradientStop Color="#FFFEFEFE" Offset="1"/>
									</LinearGradientBrush>
								</Border.Background>
								<ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
									<ItemsPresenter/>
								</ScrollViewer>
							</Border>
						</Popup>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>
